package com.shadow.baiqun.delegate.receive.adapter;

import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.shadow.baiqun.R;
import com.shadow.baiqun.config.ItemField;
import com.shadow.baiqun.delegate.receive.pregoods.PreGoodsEntry;
import com.shadow.ui.recycler.MultipleItemEntity;

import java.util.List;

/**
 * @author zy
 * on 2018/5/20
 * 预收货
 */
public class GoodsListAdapter extends BaseQuickAdapter<MultipleItemEntity, BaseViewHolder> {
    private static final int COUNT = 2;
    private int mColorWhite;
    private int mColorGray;

    public GoodsListAdapter(Context context,
                            @Nullable List<MultipleItemEntity> data,
                            int layoutResId) {
        super(layoutResId, data);
        mColorWhite = Color.WHITE;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            mColorGray = context.getColor(R.color.gray_light);
        } else {
            mColorGray = context.getResources().getColor(R.color.gray_light);
        }
    }

    @Override
    protected void convert(BaseViewHolder helper, MultipleItemEntity item) {
        PreGoodsEntry preGoodsEntry = item.getField(ItemField.ITEM_OBJ);
        helper.setText(R.id.tv_supplier_name, preGoodsEntry.getPrepgoodsSupplierName());
        String code = preGoodsEntry.getPrepgoodsStatus();
        String status = "未收货";
        if ("0".equals(code)) {
            status = "未收货";
        } else if ("1".equals(code)) {
            status = "核对完成";
        } else if ("2".equals(code)) {
            status = "标签已打印";
        } else if ("3".equals(code)) {
            status = "收货完成";
        } else if ("4".equals(code)) {
            status = "暂结收货";
        } else if ("5".equals(code)) {
            status = "待入库";
        } else if ("6".equals(code)) {
            status = "待上传送货单";
        }
        helper.setText(R.id.tv_state, status);
        String use = preGoodsEntry.getPrepgoodsUse();
        String useStr = "收货";
        if ("1".equals(use)) {
            useStr = "收货";
        } else if ("2".equals(use)) {
            useStr = "调账";
        } else if ("3".equals(use)) {
            useStr = "不良品收货";
        }
        helper.setText(R.id.tv_purpose, useStr);
        helper.setText(R.id.tv_send_time, preGoodsEntry.getPrepgoodsSendtime());
    }
}
